<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
    <#assign base=request.contextPath  />
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="${base}/js/layui/css/layui.css" media="all">
		<script src="${base}/js/layui/layui.js" charset="utf-8"></script>
		<script src="${base}/js/jquery.min.js"></script>
        <script src="${base}/js/zhang.js"></script>
		<style type="text/css">
		form{
		  padding:20px;
		}
		.layui-btn-radius{
          border-radius: 5px;
        }
		</style>
	</head>
		
	<body>
	<form class="layui-form" action="">
          <div class="layui-form-item">
              <div class="layui-inline">
                   <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;客户姓名</label>
                         <div class="layui-input-inline">
                               <input   id="userName" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                         </div>
              </div>
              <div class="layui-inline">
                  <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;预付</label>
                  <div class="layui-input-inline">
                      <input   id="setPay" lay-verify="required|number" autocomplete="off" class="layui-input isNull isNum" type="text">
                  </div>
              </div>


              <div class="layui-inline">
                  <label class="layui-form-label"><a style="color:red">*</a>&nbsp;预定套餐</label>
                  <div class="layui-input-block" >
                      <select  lay-verify="required" class="isNull" id="state">
                          <option value="">请选择套餐</option>

                      </select>
                  </div>
              </div>

              <div class="layui-inline">
                  <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;销售人员</label>
                  <div class="layui-input-inline">
                      <input name="number" id="singular" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                  </div>
              </div>

              	 <div class="layui-form-item">
                    <div class="layui-input-block">
                          <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="add()" style="background-color: #0092EF;">立即提交</button>
                          <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
                    </div>
                 </div>
          </div>
    </form>
<script>
layui.use(['form', 'layedit', 'laydate','layer'], function(){
  var form = layui.form
  	,layer = layui.layer
  	,layedit = layui.layedit
 	,laydate = layui.laydate;
  laydate.render({
    elem: '#date'
   
  });
 });

    function add(){
        if(!isNull()){
            return;
        }
         if(!isNum()){
                    return;
                }
        var requestJson={};
       requestJson.userName=$("#userName").val();
       requestJson.setPay=$("#setPay").val();
       requestJson.meal=$("#state").val();
       requestJson.outName=$("#singular").val();

        $.ajax({
            type:"POST",
            url:"${base}/dayMoney/insertDay",
            data:{"param":JSON.stringify(requestJson)},
            success : function(data){
                layer.msg(data);
                var table = parent.layui.table;
                //表刷新方法
                table.reload('testReload', {
                    url: '${base}/dayMoney/list'
                    ,where: {} //设定异步数据接口的额外参数
                });
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                setTimeout(function(){
                    parent.layer.close(index); //再执行关闭
                },700)
            }
        });
    }

//获取添加时候的套餐项
var bas = "${base}"
var home_meal = getMealName(bas,"mealName")
for(var i=0;i<home_meal.length;i++){
    $("#state").append(
            '<option value="'+home_meal[i].id+'">'+home_meal[i].mealName+'</option>'
    )
}
</script>
</body>

</html>